
<div class="modal-body no-p">
    <div class="row">
        <div class="col-xs-12">
            <section class="panel panel-primary no-b">
                <header class="panel-heading clearfix brtl brtr">
                    <div class="overflow-hidden">
                        <a href="javascript:;" class="h4 show no-m pt5">客户信息</a>
                    </div>
                    <%if(obj.state==1){%>
                    <div class="btn-group tool-button">
                        <a  href='${base}/platform/customer/documentary/add/${obj.id}'  data-toggle="modal" data-target="#dialogAddDocumentary"><i class="ti-plus"></i>添加跟单</a>
                    </div>
                    <%}%>
                    <input type="hidden" id="customerId" name="customerId" value="${obj.id}" />
                </header>
                <div class="list-group">
                    <table class="table table-bordered table-striped mg-t datatable">
                        <tbody id="table">
                                                        <tr>
                                <td>公司名称</td><td>${obj.companyName}</td>
                            </tr>
                                                        <tr>

                            </tr>
                                <tr>
                               <td>等级</td><td>${obj.level}</td>
                                </tr>
                                                        <tr>
                                <td>联系电话</td><td>${obj.telphone}</td>
                            </tr>
                                                        <tr>
                                                            <td>手机号码</td><td>${obj.mobile}</td>
                                                        </tr>
                             <tr><td>公司网址</td><td><a href="${obj.website}" target="view_window" style="color: blue">点击跳转</a></td>
                              </tr>
                                 <tr>
                                <td>地址</td><td>${obj.address}</td>
                            </tr>
                                                        <tr>
                                <td>关键词</td><td>${obj.keyword}</td>
                            </tr>
                             <%if(!isEmpty(obj.nickName)){%>
                                                        <tr>
                               <td>原业务员</td><td>${obj.nickName}</td>
                              </tr> <%}%>
                                                        <tr>
                                <td>联系人</td><td>${obj.contactsName}</td>
                            </tr>
                                                        <tr>
                                <td>主营业务</td><td>${obj.mainBusiness}</td>
                            </tr>
                                                    </tbody>
                    </table>
                </div>
                <div class=panel-body style="padding-top: 50px;">
                    <div class="table-responsive no-border">
                        <table id="documentaryDatatable_table" class="table table-bordered table-striped mg-t datatable">
                            <thead>
                            <tr>
                                <th  colspan="4" style="text-align: center;">跟单记录</th>
                            </tr>
                            <tr>
                                <th>日期</th>
                                <th>内容</th>
                                <th>下次跟进时间</th>
                                <th>跟单人员</th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </section>
        </div>
    </div>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-primary btn-block" data-dismiss="modal">知道了</button>
</div>

<script language="JavaScript">
    var documentaryDatatable;
    function initDocumentaryDatatable() {
        documentaryDatatable = $('#documentaryDatatable_table').DataTable({
            "dom": '<"toolbar">frtip',
            "searching":false,
            "processing": false,
            "serverSide": true,
            "select": true,
            "ordering": true,
            "language": {
                "url": "${base}/assets/plugins/datatables/cn.json"
            },
            "preDrawCallback": function () {
                sublime.showLoadingbar($(".main-content"));
            },
            "drawCallback": function () {
                sublime.closeLoadingbar($(".main-content"));
            },
            "ajax": {
                "url": "${base}/platform/customer/documentary/list",
                "type": "post",
                "data": function (d) {
                    //d.nutz = $('#nutz').val();
                    d.customerId=$("#customerId").val();
                }
            },
            "order": [[0, "desc"]],
            "columns": [
                {"data": "opAt", "bSortable": true},
                {"data": "content", "bSortable": true},
                {"data": "documentaryTime", "bSortable": true},
                {"data": "nickName", "bSortable": true},
            ],

            "columnDefs": [
                {
                    "render": function (data, type, row) {
                        if (data) {
                            return moment(parseInt(data*1000)).format("YYYY-MM-DD HH:mm:ss");
                        }
                        return '';
                    },
                    "targets": 0
                },
                {
                    "render": function (data, type, row) {
                        if (data) {
                            return moment(parseInt(data*1000)).format("YYYY-MM-DD HH:mm:ss");
                        }
                        return '';
                    },
                    "targets": 2
                }
            ]
        });
        documentaryDatatable.on('click', 'tr', function () {
            $(this).toggleClass('selected');
        });
    }

    function delDocumentary(id) {
        var dialog = $("#dialogDelete");
        dialog.modal("show");
        dialog.find("#okDel").unbind("click");
        dialog.find("#okDel").bind("click", function (event) {
            var btn = $(this);
            btn.button("loading");
            $.post("${base}/platform/customer/documentary/delete/" + id, {}, function (data) {
                if (data.code == 0) {
                    datatable.ajax.reload(null,false);
                } else {
                    Toast.error(data.msg);
                }
                //重置按钮状态，关闭提示框
                btn.button("reset");
                dialog.modal("hide");
            }, "json");
        });
    }
    function changeDateFormat(cellval) {
        var dateVal = cellval + "";
        if (cellval != null) {
            var date = new Date(parseInt(dateVal.replace("/Date(", "").replace(")/", ""), 10));
            var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
            var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();

            var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
            var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
            var seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();

            return date.getFullYear() + "-" + month + "-" + currentDate + " " + hours + ":" + minutes + ":" + seconds;
        }
    }
    $(function () {
        initDocumentaryDatatable();
        $("#dialogAddDocumentary").on("hidden.bs.modal", function () {
            documentaryDatatable.ajax.reload(null,false);
        });
    });
    </script>